//
//  WKCollectionCompleteCell.m
//  WeKeTang
//
//  Created by ichina on 2017/9/25.
//  Copyright © 2017年 Dezhi Tiancheng Education Technology (Beijing) Co. Ltd. All rights reserved.
//

#import "WKCollectionCompleteCell.h"
#import <UIImageView+WebCache.h>

@interface WKCollectionCompleteCell ()

@property (nonatomic, strong) UIImageView *iconImageView;

@property (nonatomic, strong) YYLabel *titleLabel;

@property (nonatomic, strong) YYLabel *tipLabel;

@end

@implementation WKCollectionCompleteCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        [self setupUI];
    }
    return self;
}
- (void)setupUI{
    
    self.iconImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:self.iconImageView];
    
    self.titleLabel = [[YYLabel alloc]init];
    [self.contentView addSubview:self.titleLabel];
    self.titleLabel.font = [UIFont systemFontOfSize:13];
    self.titleLabel.numberOfLines = 0;
    self.titleLabel.textColor = [UIColor blackColor];
    
    self.tipLabel = [[YYLabel alloc]init];
    [self.contentView addSubview:self.tipLabel];
    self.tipLabel.textAlignment = NSTextAlignmentLeft;
    self.tipLabel.font = [UIFont systemFontOfSize:13];
    self.tipLabel.numberOfLines = 0;
    self.tipLabel.textColor = [UIColor colorWithHexString:@"#666666"];
}
- (void)setModel:(WKCollectionCompleteModel *)model{
    
    _model = model;

    NSString *imgUrl = [model.pack_imgurl stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
    NSString *url = [NSString stringWithFormat:@"%@%@",kTestMainUrl,imgUrl];
//    NSLog(@"整个图片地址：%@",url);
//    NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
//    UIImage *image = [UIImage imageWithData:data];
    [self.iconImageView setImageWithURL:[NSURL URLWithString:url] options:YYWebImageOptionShowNetworkActivity];
    
    self.titleLabel.text = model.pack_name;
    self.tipLabel.text = [NSString stringWithFormat:@"共%@节",model.section_num];
    
}
- (void)layoutSubviews{
    
    [super layoutSubviews];
    
    self.iconImageView.frame =CGRectMake(10, 10, 140, 120-20);
    self.titleLabel.frame =CGRectMake(CGRectGetMaxX(self.iconImageView.frame)+10, 5, kDeviceScreenWidth-20-140-10, 42);
    self.tipLabel.frame =CGRectMake(CGRectGetMaxX(self.iconImageView.frame)+10, CGRectGetMaxY(self.iconImageView.frame)-15, 50, 21);
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    
}

@end
